#@head() 
#@header()
<title>融资需求管理</title>
#@aside("custser")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom" >
            <ul class="nav nav-tabs">
              <li class="" ><a href="#(path)/admin/page/custser-come" style="cursor:pointer" >客户访问</a></li>
			  <li class="active"><a href="#(path)/admin/page/custser-workorder" style="cursor:pointer">工单</a></li>
            </ul>
            <div class="tab-content">
              <!-- 来访 -->
			  <div class="tab-pane active" id="tab_1">
				<div class="input-group margin" style="width:60%;float:left">
					<label style="float:left;margin-top:8px;margin-left:5px;">真实姓名：</label>
					<input type="text" id="realname" style="width:150px;margin-right:20px;" class="form-control" placeholder="" >
					<label style="float:left;margin-top:8px;margin-left:5px;">用户名：</label>
					<input type="text" id="usermobile" style="width:150px;" class="form-control" placeholder="" >
					<label style="float:left;margin-top:8px;margin-left:20px;">访问时间：</label>
					<input type="text" id="starttime" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:120px;float:left;margin-left:10px;">
					<span style="float:left;margin:5px 5px 0 5px;">—</span> 
					<input type="text" id="endtime" class="form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width:120px;float:left;margin-right:20px;">
					
					<span style="float:left;margin-left:20px" class="input-group-btn">
					  <button id="visitsubmits" type="button" class="btn btn-info btn-flat">搜索</button>
					</span>
				</div>
				<div class="box-body">
					<table  id="example1" class="table table-striped">
						<thead>
							<tr>		
								<th>ID</th>
								<th>来访时间</th>
								<th>真实姓名</th>
								<th>用户名</th>
								<th>所属客服</th>
								<th>创建人</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="userlist">
							
						</tbody>
					</table>
					<div class="box-footer clearfix">
					  <ul class="pagination pagination-sm no-margin pull-right">
						<li id="userlist1"><a href="#">首页</a></li>
						<li id="userlist2"><a href="#">上一页</a></li>
						<li><a href="#">第<span id="userlist5"></span>页 共<span id="userlist6"></span>页</a></li>
						<li id="userlist3"><a href="#">下一页</a></li>
						<li id="userlist4"><a href="#">尾页</a></li>
					  </ul>
					</div>
				</div>
			</div>
		</div>
	</div> 
	</section>
</div>
#@footer()
<script id="userlistall" type="text/x-jquery-tmpl">
	<tr>
		<td>${id}</td>
		<td>${create_time}</td>
		<td>${real_name}</td>
		<td>${mobile}</td>
		<td>${agent_real_name}</td>
		<td>${creater_real_name}</td>
		<td>
			<div class="btn-group">
			  <button  onclick="${clickurl}" type="button" class="btn ${cla}">${anniu}</button>
			</div>
		</td>
	</tr>
</script>

<script>
 $(document).ready(function(){
		var totalPage = 1;
		var pageNumber = 1;
		var usermobile = "";
		var realname = '';
		var starttime = '';
		var endtime = '';
		pageNumber = 1;
		
		$("#userlist").empty();
		userlist(pageNumber,usermobile,realname,starttime,endtime);
		$("#userlist5").html(pageNumber);
		$("#userlist1").click(function(){
			$("#userlist").empty();
			pageNumber = 1;
			userlist(pageNumber,usermobile,realname,starttime,endtime);
			$("#userlist5").html(pageNumber);
		});
		$("#userlist2").click(function(){
			if(pageNumber==1){
				alert("当前页是首页!");
			}else{
			$("#userlist").empty();
			pageNumber = pageNumber-1;
			userlist(pageNumber,usermobile,realname,starttime,endtime);
			$("#userlist5").html(pageNumber);
			}
		});
		$("#userlist3").click(function(){
			if(pageNumber==totalPage){
				alert("当前页是尾页!");
			}else{
				$("#userlist").empty();
				pageNumber = pageNumber +1;
				userlist(pageNumber,usermobile,realname,starttime,endtime);
				$("#userlist5").html(pageNumber);
			}
		});
		$("#userlist4").click(function(){
			$("#userlist").empty();
			pageNumber = totalPage;
			userlist(pageNumber,usermobile,realname,starttime,endtime);
			$("#userlist5").html(pageNumber);
		});
		$("#visitsubmits").click(function(){
			$("#userlist").empty();
			usermobile = $("#usermobile").val();
			realname = $("#realname").val();
			starttime = $("#starttime").val();
			endtime = $("#endtime").val();
			pageNumber = totalPage; 
			userlist(pageNumber,usermobile,realname,starttime,endtime);
			$("#userlist5").html(pageNumber);
		});
		function userlist(pageNumber,usermobile,realname,starttime,endtime){
			$.getJSON("/visit/list?token=#(session.token??)&page="+pageNumber+"&size=12&isSolve=0&moible="+usermobile+"&realName="+realname+"&createTimeStart="+starttime+"&createTimeEnd="+endtime, function(userli) {
				console.log(userli); 
				totalPage = userli.data.page.totalPage; 
				$("#userlist6").html(totalPage);
				$.each(userli.data.page.list, function(i, item){ 
					if(item.type=="back"){type="回访" }
						else if(item.type=="come"){type="来访" }
					if(item.is_solve==0){
						var clickurl = "window.location.href='#(path)/admin/page/custser-orderinfo?id="+item.id+"'";
						var anniu = "处理";
						var cla = "btn-warning";
					}else if(item.is_solve==1){
						var clickurl = "window.location.href='#(path)/admin/page/custser-orderinfo?id="+item.id+"'";
						var anniu = "查看";
						var cla = "btn-success";
					}
					var userlist = {creater_real_name:item.creater_real_name,clickurl:clickurl,anniu:anniu,cla:cla,agent_real_name:item.agent_real_name,create_time:item.create_time,id:item.id,is_valid:item.is_valid,matter:item.matter,mobile:item.mobile,real_name:item.real_name,solve:item.solve,tel:item.tel,user_id:item.user_id};
					$("#userlistall").tmpl(userlist).appendTo('#userlist');
				});
			});	
		}
		
});
   
</script> 

</body>
</html>

